package co.com.smart.session;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import co.com.bean.afiliacion.AfiliacionBeanLocal;
import co.com.bean.agenda.AgendaBeanLocal;
import co.com.bean.citas.CitaBeanLocal;
import co.com.bean.consultorio.ConsultorioBeanLocal;
import co.com.bean.datosmaestros.DatosMaestrosBeanLocal;
import co.com.bean.departamento.DepartamentoBeanLocal;
import co.com.bean.eps.EpsBeanLocal;
import co.com.bean.especialidad.EspecialidadBeanLocal;
import co.com.bean.institucion.InstitucionBeanLocal;
import co.com.bean.medico.MedicoBeanLocal;
import co.com.bean.pacientes.PacientesBeanLocal;
import co.com.bean.pais.PaisBeanLocal;
import co.com.bean.persona.PersonaBeanLocal;
import co.com.bean.planservicio.PlanServicioBeanLocal;
import co.com.bean.sede.SedeBeanLocal;
import co.com.smart.persistence.entity.AfiliacionFacadeLocal;
import co.com.smart.persistence.entity.AgendaFacadeLocal;
import co.com.smart.persistence.entity.CitasFacadeLocal;
import co.com.smart.persistence.entity.CiudadFacadeLocal;
import co.com.smart.persistence.entity.ConsultorioFacadeLocal;
import co.com.smart.persistence.entity.DatosMaestrosFacadeLocal;
import co.com.smart.persistence.entity.DepartamentoFacadeLocal;
import co.com.smart.persistence.entity.EpsFacadeLocal;
import co.com.smart.persistence.entity.EspecialidadFacadeLocal;
import co.com.smart.persistence.entity.InstitucionFacadeLocal;
import co.com.smart.persistence.entity.MedicoFacadeLocal;
import co.com.smart.persistence.entity.PacientesFacadeLocal;
import co.com.smart.persistence.entity.PaisFacadeLocal;
import co.com.smart.persistence.entity.PersonaFacadeLocal;
import co.com.smart.persistence.entity.PlanServicioFacadeLocal;
import co.com.smart.persistence.entity.SedeFacadeLocal;
import co.com.smart.persistence.entity.ZonaFacadeLocal;

public class DelegateContextEJB {

	/**
	 * Beans EJB delegate
	 */
	private static PaisBeanLocal paisBeanLocal;
	private static DepartamentoBeanLocal departamentoBeanLocal;
	private static MedicoBeanLocal medicoBeanLocal;
	private static PersonaBeanLocal personaBeanLocal ;
	private static PlanServicioBeanLocal planServicioBeanLocal ;
	private static EspecialidadBeanLocal especialidadBeanLocal ;
	private static DatosMaestrosBeanLocal datosMaestrosBeanLocal ;
	private static AgendaBeanLocal agendaBeanLocal ;
	private static ConsultorioBeanLocal consultorioBeanLocal ;
	private static SedeBeanLocal sedeBeanLocal ;
	private static InstitucionBeanLocal institucionBeanLocal ;
	private static EpsBeanLocal epsBeanLocal ;
	private static PacientesBeanLocal pacientesBeanLocal ;
	private static AfiliacionBeanLocal afiliacionBeanLocal ;
	private static CitaBeanLocal citaBeanLocal ;

	/**
	 * Beans Facade persistentes
	 */
	private static PaisFacadeLocal paisFacadeLocal;
	private static DepartamentoFacadeLocal departamentoFacadeLocal;
	private static CiudadFacadeLocal ciudadFacadeLocal;
	private static ZonaFacadeLocal zonaFacadeLocal;
	private static MedicoFacadeLocal medicoFacadeLocal;
	private static PersonaFacadeLocal personaFacadeLocal;
	private static PlanServicioFacadeLocal planServicioFacadeLocal ;
	private static EspecialidadFacadeLocal especialidadFacadeLocal ;
	private static DatosMaestrosFacadeLocal datosMaestrosFacadeLocal ;
	private static AgendaFacadeLocal agendaFacadeLocal ;
	private static ConsultorioFacadeLocal consultorioFacadeLocal ;
	private static SedeFacadeLocal sedeFacadeLocal ;
	private static InstitucionFacadeLocal institucionFacadeLocal ;
	private static EpsFacadeLocal epsFacadeLocal ;
	private static PacientesFacadeLocal pacientesFacadeLocal ;
	private static AfiliacionFacadeLocal afiliacionFacadeLocal ;
	private static CitasFacadeLocal citasFacadeLocal ;



	/**
	 * BEANS 
	 */
	public static PaisBeanLocal getPaisBeanLocal(){

		if(paisBeanLocal == null){
			try {
				paisBeanLocal = (PaisBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PaisBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return paisBeanLocal;

	}

	public static DepartamentoBeanLocal getDepartamentoBeanLocal(){

		if(departamentoBeanLocal == null){
			try {
				departamentoBeanLocal = (DepartamentoBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/DepartamentoBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return departamentoBeanLocal;

	}
	
	public static MedicoBeanLocal getMedicoBeanLocal(){

		if(medicoBeanLocal == null){
			try {
				medicoBeanLocal = (MedicoBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/MedicoBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return medicoBeanLocal;

	}
	
	public static PersonaBeanLocal getPersonaBeanLocal(){

		if(personaBeanLocal == null){
			try {
				personaBeanLocal = (PersonaBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PersonaBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return personaBeanLocal;

	}
	
	public static PlanServicioBeanLocal getPlanServicioBeanLocal(){

		if(planServicioBeanLocal == null){
			try {
				planServicioBeanLocal = (PlanServicioBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PlanServicioBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return planServicioBeanLocal;

	}
	
	public static EspecialidadBeanLocal getEspecialidadBeanLocal(){

		if(especialidadBeanLocal == null){
			try {
				especialidadBeanLocal = (EspecialidadBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/EspecialidadBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return especialidadBeanLocal;

	}
	
	public static DatosMaestrosBeanLocal getDatosMaestrosBeanLocal(){

		if(datosMaestrosBeanLocal == null){
			try {
				datosMaestrosBeanLocal = (DatosMaestrosBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/DatosMaestrosBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return datosMaestrosBeanLocal;

	}
	
	
	public static AgendaBeanLocal getAgendaBeanLocal(){

		if(agendaBeanLocal == null){
			try {
				agendaBeanLocal = (AgendaBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/AgendaBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return agendaBeanLocal;

	}
	
	public static ConsultorioBeanLocal getConsultorioBeanLocal(){

		if(consultorioBeanLocal == null){
			try {
				consultorioBeanLocal = (ConsultorioBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/ConsultorioBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return consultorioBeanLocal;

	}
	
	public static SedeBeanLocal getSedeBeanLocal(){

		if(sedeBeanLocal == null){
			try {
				sedeBeanLocal = (SedeBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/SedeBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return sedeBeanLocal;

	}
	
	public static InstitucionBeanLocal getInstitucionBeanLocal(){

		if(institucionBeanLocal == null){
			try {
				institucionBeanLocal = (InstitucionBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/InstitucionBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return institucionBeanLocal;

	}
	
	public static EpsBeanLocal getEpsBeanLocal(){

		if(epsBeanLocal == null){
			try {
				epsBeanLocal = (EpsBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/EpsBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return epsBeanLocal;

	}
	
	public static PacientesBeanLocal getPacientesBeanLocal(){

		if(pacientesBeanLocal == null){
			try {
				pacientesBeanLocal = (PacientesBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PacientesBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return pacientesBeanLocal;

	}
	
	public static AfiliacionBeanLocal getAfiliacionBeanLocal(){

		if(afiliacionBeanLocal == null){
			try {
				afiliacionBeanLocal = (AfiliacionBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/AfiliacionBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return afiliacionBeanLocal;

	}
	
	public static CitaBeanLocal getCitaBeanLocal(){

		if(citaBeanLocal == null){
			try {
				citaBeanLocal = (CitaBeanLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/CitaBean");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return citaBeanLocal;

	}

	/**
	 * FACADES
	 */


	public static PaisFacadeLocal getPaisFacadeLocal(){

		if(paisFacadeLocal == null){
			try {
				paisFacadeLocal = (PaisFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PaisFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return paisFacadeLocal;
	}

	public static DepartamentoFacadeLocal getDepartamentoFacadeLocal(){

		if(departamentoFacadeLocal == null){
			try {
				departamentoFacadeLocal = (DepartamentoFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/DepartamentoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return departamentoFacadeLocal;
	}

	public static CiudadFacadeLocal getCiudadFacadeLocal(){

		if(ciudadFacadeLocal == null){
			try {
				ciudadFacadeLocal = (CiudadFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/CiudadFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return ciudadFacadeLocal;
	}

	public static ZonaFacadeLocal getZonaFacadeLocal(){

		if(zonaFacadeLocal == null){
			try {
				zonaFacadeLocal = (ZonaFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/ZonaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return zonaFacadeLocal;
	}
	
	public static MedicoFacadeLocal getMedicoFacadeLocal(){

		if(medicoFacadeLocal == null){
			try {
				medicoFacadeLocal = (MedicoFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/MedicoFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return medicoFacadeLocal;
	}
	
	public static PersonaFacadeLocal getPersonaFacadeLocal(){

		if(personaFacadeLocal == null){
			try {
				personaFacadeLocal = (PersonaFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PersonaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return personaFacadeLocal;
	}
	
	public static PlanServicioFacadeLocal getPlanServicioFacadeLocal(){

		if(planServicioFacadeLocal == null){
			try {
				planServicioFacadeLocal = (PlanServicioFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PlanServicioFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return planServicioFacadeLocal;
	}
	
	public static EspecialidadFacadeLocal getEspecialidadFacadeLocal(){

		if(especialidadFacadeLocal == null){
			try {
				especialidadFacadeLocal = (EspecialidadFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/EspecialidadFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return especialidadFacadeLocal;
	}
	
	public static DatosMaestrosFacadeLocal getDatosMaestrosFacadeLocal(){

		if(datosMaestrosFacadeLocal == null){
			try {
				datosMaestrosFacadeLocal = (DatosMaestrosFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/DatosMaestrosFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return datosMaestrosFacadeLocal;
	}
	
	public static AgendaFacadeLocal getAgendaFacadeLocal(){

		if(agendaFacadeLocal == null){
			try {
				agendaFacadeLocal = (AgendaFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/AgendaFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return agendaFacadeLocal;
	}
	
	public static ConsultorioFacadeLocal getConsultorioFacadeLocal(){

		if(consultorioFacadeLocal == null){
			try {
				consultorioFacadeLocal = (ConsultorioFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/ConsultorioFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return consultorioFacadeLocal;
	}
	
	public static SedeFacadeLocal getSedeFacadeLocal(){

		if(sedeFacadeLocal == null){
			try {
				sedeFacadeLocal = (SedeFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/SedeFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return sedeFacadeLocal;
	}
	
	public static InstitucionFacadeLocal getInstitucionFacadeLocal(){

		if(institucionFacadeLocal == null){
			try {
				institucionFacadeLocal = (InstitucionFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/InstitucionFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return institucionFacadeLocal;
	}

	public static EpsFacadeLocal getEpsFacadeLocal(){

		if(epsFacadeLocal == null){
			try {
				epsFacadeLocal = (EpsFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/EpsFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return epsFacadeLocal;
	}
	
	public static PacientesFacadeLocal getPacientesFacadeLocal(){

		if(pacientesFacadeLocal == null){
			try {
				pacientesFacadeLocal = (PacientesFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/PacientesFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return pacientesFacadeLocal;
	}
	
	public static AfiliacionFacadeLocal getAfiliacionFacadeLocal(){

		if(afiliacionFacadeLocal == null){
			try {
				afiliacionFacadeLocal = (AfiliacionFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/AfiliacionFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return afiliacionFacadeLocal;
	}
	
	public static CitasFacadeLocal getCitasFacadeLocal(){

		if(citasFacadeLocal == null){
			try {
				citasFacadeLocal = (CitasFacadeLocal) new InitialContext().lookup("java:global/SnakeServicesEAR/SnakeServicesEJB/CitasFacade");
			} catch (NamingException e) {
				System.out.println("Error recuperando el servicio "+ e.getMessage());
			}
		}

		return citasFacadeLocal;
	}
}
